package br.com.moto.web;


import br.com.moto.ejb.FotoHomeSessionBean;
import javax.annotation.PostConstruct;
import br.com.moto.ejb.FotoSessionBean;
import br.com.moto.ejb.PessoaSessionBean;
import br.com.moto.entity.Album;
import br.com.moto.entity.Foto;
import br.com.moto.entity.FotoHome;
import br.com.moto.entity.Pessoa;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext; 
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.RateEvent;
import org.primefaces.model.UploadedFile;

@ManagedBean(name = "fotoHomeController")
@SessionScoped
public class FotoHomeMBean { 
    
    @EJB
    private FotoHomeSessionBean fotoSessionBean;

    private List<FotoHome> fotosHome;
     
    private FotoHome selectedCar;      
    
    public FotoHomeMBean() { } 
    
    public FotoHome getFotoHome() { 
        List lista = fotoSessionBean.retrieve();  
        
        int i = (int) (1+Math.random() * (lista.size() - 1));
        return (FotoHome) lista.get(i);
    }
     

    public List<FotoHome> getFotosHome() {
        
        fotosHome = new ArrayList<FotoHome>(); 
        fotosHome.addAll(fotoSessionBean.retrieve());
        
        return fotosHome;
    }

    public void setFotosHome(List<FotoHome> fotosHome) {
        this.fotosHome = fotosHome; 
    }
     
    
    public FotoHome getSelectedCar() {  
        return selectedCar;  
    }  
  
    public void setSelectedCar(FotoHome selectedCar) {  
        this.selectedCar = selectedCar;  
    }  
}
   